home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 October: Mac OS SDK / Dev.CD Oct 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Universal / Interfaces / CIncludes / OSUtils.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-12  |  10.1 KB  |  398 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        OSUtils.h
  3.  
  4.      Contains:    OS Utilities Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.0.1
  8.  
  9.      Copyright:    © 1985-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __OSUTILS__
  19. #define __OSUTILS__
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. #ifndef __MIXEDMODE__
  25. #include <MixedMode.h>
  26. #endif
  27. /*  HandToHand and other memory utilties were moved to MacMemory.h */
  28. #ifndef __MACMEMORY__
  29. #include <MacMemory.h>
  30. #endif
  31. /*  GetTrapAddress and other trap table utilties were moved to Patches.h */
  32. #ifndef __PATCHES__
  33. #include <Patches.h>
  34. #endif
  35. /*  Date and Time utilties were moved to DateTimeUtils.h */
  36. #ifndef __DATETIMEUTILS__
  37. #include <DateTimeUtils.h>
  38. #endif
  39.  
  40.  
  41.  
  42. #if PRAGMA_ONCE
  43. #pragma once
  44. #endif
  45.  
  46. #ifdef __cplusplus
  47. extern "C" {
  48. #endif
  49.  
  50. #if PRAGMA_IMPORT
  51. #pragma import on
  52. #endif
  53.  
  54. #if PRAGMA_STRUCT_ALIGN
  55.     #pragma options align=mac68k
  56. #elif PRAGMA_STRUCT_PACKPUSH
  57.     #pragma pack(push, 2)
  58. #elif PRAGMA_STRUCT_PACK
  59.     #pragma pack(2)
  60. #endif
  61.  
  62.  
  63. enum {
  64.     useFree                        = 0,
  65.     useATalk                    = 1,
  66.     useAsync                    = 2,
  67.     useExtClk                    = 3,                            /*Externally clocked*/
  68.     useMIDI                        = 4
  69. };
  70.  
  71.  
  72. enum {
  73.     false32b                    = 0,                            /*24 bit addressing error*/
  74.     true32b                        = 1                                /*32 bit addressing error*/
  75. };
  76.  
  77.  
  78. enum {
  79.                                                                 /* result types for RelString Call */
  80.     sortsBefore                    = -1,                            /*first string < second string*/
  81.     sortsEqual                    = 0,                            /*first string = second string*/
  82.     sortsAfter                    = 1                                /*first string > second string*/
  83. };
  84.  
  85.  
  86. enum {
  87.     dummyType                    = 0,
  88.     vType                        = 1,
  89.     ioQType                        = 2,
  90.     drvQType                    = 3,
  91.     evType                        = 4,
  92.     fsQType                        = 5,
  93.     sIQType                        = 6,
  94.     dtQType                        = 7,
  95.     nmType                        = 8
  96. };
  97.  
  98. typedef SignedByte                         QTypes;
  99. struct SysParmType {
  100.     UInt8                             valid;
  101.     UInt8                             aTalkA;
  102.     UInt8                             aTalkB;
  103.     UInt8                             config;
  104.     short                             portA;
  105.     short                             portB;
  106.     long                             alarm;
  107.     short                             font;
  108.     short                             kbdPrint;
  109.     short                             volClik;
  110.     short                             misc;
  111. };
  112. typedef struct SysParmType SysParmType;
  113.  
  114. typedef SysParmType *                    SysPPtr;
  115. struct QElem {
  116.     struct QElem *                    qLink;
  117.     short                             qType;
  118.     short                             qData[1];
  119. };
  120. typedef struct QElem QElem;
  121.  
  122. typedef QElem *                            QElemPtr;
  123. struct QHdr {
  124.     short                             qFlags;
  125.     QElemPtr                         qHead;
  126.     QElemPtr                         qTail;
  127. };
  128. typedef struct QHdr QHdr;
  129.  
  130. typedef QHdr *                            QHdrPtr;
  131.  
  132.  
  133. typedef CALLBACK_API( void , DeferredTaskProcPtr )(long dtParam);
  134. /*
  135.     WARNING: DeferredTaskProcPtr uses register based parameters under classic 68k
  136.              and cannot be written in a high-level language without 
  137.              the help of mixed mode or assembly glue.
  138. */
  139. typedef REGISTER_UPP_TYPE(DeferredTaskProcPtr)                     DeferredTaskUPP;
  140. enum { uppDeferredTaskProcInfo = 0x0000B802 };                     /* register no_return_value Func(4_bytes:A1) */
  141. #define NewDeferredTaskProc(userRoutine)                         (DeferredTaskUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppDeferredTaskProcInfo, GetCurrentArchitecture())
  142. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  143.     #pragma parameter CallDeferredTaskProc(__A0, __A1)
  144.     void CallDeferredTaskProc(DeferredTaskUPP routine, long dtParam) = 0x4E90;
  145. #else
  146.     #define CallDeferredTaskProc(userRoutine, dtParam)             CALL_ONE_PARAMETER_UPP((userRoutine), uppDeferredTaskProcInfo, (dtParam))
  147. #endif
  148. struct DeferredTask {
  149.     QElemPtr                         qLink;
  150.     short                             qType;
  151.     short                             dtFlags;
  152.     DeferredTaskUPP                 dtAddr;
  153.     long                             dtParam;
  154.     long                             dtReserved;
  155. };
  156. typedef struct DeferredTask DeferredTask;
  157.  
  158. typedef DeferredTask *                    DeferredTaskPtr;
  159. struct MachineLocation {
  160.     Fract                             latitude;
  161.     Fract                             longitude;
  162.     union {
  163.         SInt8                             dlsDelta;                /* signed byte; daylight savings delta */
  164.         long                             gmtDelta;                /* use low 24-bits only */
  165.     }                                 u;
  166. };
  167. typedef struct MachineLocation MachineLocation;
  168.  
  169.  
  170. EXTERN_API( Boolean )
  171. IsMetric                        (void)                                                        THREEWORDINLINE(0x3F3C, 0x0004, 0xA9ED);
  172.  
  173. EXTERN_API( SysPPtr )
  174. GetSysPPtr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x01F8);
  175.  
  176.  
  177. /*
  178.     NOTE: SysBeep() has been moved to Sound.h.  
  179.           We could not automatically #include Sound.h in this file
  180.           because Sound.h indirectly #include's OSUtils.h which
  181.           would make a circular include.
  182. */
  183.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  184.                                                                                             #pragma parameter __D0 DTInstall(__A0)
  185.                                                                                             #endif
  186. EXTERN_API( OSErr )
  187. DTInstall                        (DeferredTaskPtr         dtTaskPtr)                            ONEWORDINLINE(0xA082);
  188.  
  189.  
  190.  
  191. #if TARGET_CPU_PPC
  192. #define GetMMUMode() ((SInt8)true32b)
  193. #define SwapMMUMode(x) (*(SInt8*)(x) = true32b)
  194. #else
  195. EXTERN_API( SInt8 )
  196. GetMMUMode                        (void)                                                        TWOWORDINLINE(0x1EB8, 0x0CB2);
  197.  
  198.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  199.                                                                                             #pragma parameter SwapMMUMode(__A0)
  200.                                                                                             #endif
  201. EXTERN_API( void )
  202. SwapMMUMode                        (SInt8 *                mode)                                THREEWORDINLINE(0x1010, 0xA05D, 0x1080);
  203.  
  204. #endif
  205.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  206.                                                                                             #pragma parameter Delay(__A0, __A1)
  207.                                                                                             #endif
  208. EXTERN_API( void )
  209. Delay                            (unsigned long             numTicks,
  210.                                  unsigned long *        finalTicks)                            TWOWORDINLINE(0xA03B, 0x2280);
  211.  
  212.  
  213. EXTERN_API( OSErr )
  214. WriteParam                        (void);
  215.  
  216.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  217.                                                                                             #pragma parameter Enqueue(__A0, __A1)
  218.                                                                                             #endif
  219. EXTERN_API( void )
  220. Enqueue                            (QElemPtr                 qElement,
  221.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96F);
  222.  
  223.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  224.                                                                                             #pragma parameter __D0 Dequeue(__A0, __A1)
  225.                                                                                             #endif
  226. EXTERN_API( OSErr )
  227. Dequeue                            (QElemPtr                 qElement,
  228.                                  QHdrPtr                 qHeader)                            ONEWORDINLINE(0xA96E);
  229.  
  230.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  231.                                                                                             #pragma parameter __D0 SetCurrentA5
  232.                                                                                             #endif
  233. EXTERN_API( long )
  234. SetCurrentA5                    (void)                                                        THREEWORDINLINE(0x200D, 0x2A78, 0x0904);
  235.  
  236.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  237.                                                                                             #pragma parameter __D0 SetA5(__D0)
  238.                                                                                             #endif
  239. EXTERN_API( long )
  240. SetA5                            (long                     newA5)                                ONEWORDINLINE(0xC18D);
  241.  
  242.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  243.                                                                                             #pragma parameter __D0 InitUtil
  244.                                                                                             #endif
  245. EXTERN_API( OSErr )
  246. InitUtil                        (void)                                                        ONEWORDINLINE(0xA03F);
  247.  
  248.  
  249. #if TARGET_CPU_PPC
  250. EXTERN_API( void )
  251. MakeDataExecutable                (void *                    baseAddress,
  252.                                  unsigned long             length);
  253.  
  254. #endif  /* TARGET_CPU_PPC */
  255.  
  256. #if TARGET_CPU_68K
  257. EXTERN_API( Boolean )
  258. SwapInstructionCache            (Boolean                 cacheEnable);
  259.  
  260. EXTERN_API( void )
  261. FlushInstructionCache            (void)                                                        TWOWORDINLINE(0x7001, 0xA098);
  262.  
  263. EXTERN_API( Boolean )
  264. SwapDataCache                    (Boolean                 cacheEnable);
  265.  
  266. EXTERN_API( void )
  267. FlushDataCache                    (void)                                                        TWOWORDINLINE(0x7003, 0xA098);
  268.  
  269. EXTERN_API( void )
  270. FlushCodeCache                    (void)                                                        ONEWORDINLINE(0xA0BD);
  271.  
  272.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  273.                                                                                             #pragma parameter __D0 FlushCodeCacheRange(__A0, __A1)
  274.                                                                                             #endif
  275. EXTERN_API( OSErr )
  276. FlushCodeCacheRange                (void *                    address,
  277.                                  unsigned long             count)                                TWOWORDINLINE(0x7009, 0xA098);
  278.  
  279. #endif  /* TARGET_CPU_68K */
  280.  
  281.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  282.                                                                                             #pragma parameter ReadLocation(__A0)
  283.                                                                                             #endif
  284. EXTERN_API( void )
  285. ReadLocation                    (MachineLocation *        loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA051);
  286.  
  287.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  288.                                                                                             #pragma parameter WriteLocation(__A0)
  289.                                                                                             #endif
  290. EXTERN_API( void )
  291. WriteLocation                    (const MachineLocation * loc)                                FOURWORDINLINE(0x203C, 0x000C, 0x00E4, 0xA052);
  292.  
  293.  
  294.  
  295. #if OLDROUTINENAMES
  296. #define IUMetric() IsMetric()
  297. #endif  /* OLDROUTINENAMES */
  298.  
  299. /*
  300.     NOTE: SysEnvirons is obsolete.  You should be using Gestalt.
  301. */
  302. /* Environs Equates */
  303.  
  304. enum {
  305.     curSysEnvVers                = 2                                /*Updated to equal latest SysEnvirons version*/
  306. };
  307.  
  308. struct SysEnvRec {
  309.     short                             environsVersion;
  310.     short                             machineType;
  311.     short                             systemVersion;
  312.     short                             processor;
  313.     Boolean                         hasFPU;
  314.     Boolean                         hasColorQD;
  315.     short                             keyBoardType;
  316.     short                             atDrvrVersNum;
  317.     short                             sysVRefNum;
  318. };
  319. typedef struct SysEnvRec SysEnvRec;
  320.  
  321.  
  322. enum {
  323.                                                                 /* Machine Types */
  324.     envMac                        = -1,
  325.     envXL                        = -2,
  326.     envMachUnknown                = 0,
  327.     env512KE                    = 1,
  328.     envMacPlus                    = 2,
  329.     envSE                        = 3,
  330.     envMacII                    = 4,
  331.     envMacIIx                    = 5,
  332.     envMacIIcx                    = 6,
  333.     envSE30                        = 7,
  334.     envPortable                    = 8,
  335.     envMacIIci                    = 9,
  336.     envMacIIfx                    = 11
  337. };
  338.  
  339.  
  340. enum {
  341.                                                                 /* CPU types */
  342.     envCPUUnknown                = 0,
  343.     env68000                    = 1,
  344.     env68010                    = 2,
  345.     env68020                    = 3,
  346.     env68030                    = 4,
  347.     env68040                    = 5
  348. };
  349.  
  350.  
  351. enum {
  352.                                                                 /* Keyboard types */
  353.     envUnknownKbd                = 0,
  354.     envMacKbd                    = 1,
  355.     envMacAndPad                = 2,
  356.     envMacPlusKbd                = 3,
  357.     envAExtendKbd                = 4,
  358.     envStandADBKbd                = 5,
  359.     envPrtblADBKbd                = 6,
  360.     envPrtblISOKbd                = 7,
  361.     envStdISOADBKbd                = 8,
  362.     envExtISOADBKbd                = 9
  363. };
  364.  
  365.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  366.                                                                                             #pragma parameter __D0 SysEnvirons(__D0, __A0)
  367.                                                                                             #endif
  368. EXTERN_API( OSErr )
  369. SysEnvirons                        (short                     versionRequested,
  370.                                  SysEnvRec *            theWorld)                            ONEWORDINLINE(0xA090);
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378. #if PRAGMA_STRUCT_ALIGN
  379.     #pragma options align=reset
  380. #elif PRAGMA_STRUCT_PACKPUSH
  381.     #pragma pack(pop)
  382. #elif PRAGMA_STRUCT_PACK
  383.     #pragma pack()
  384. #endif
  385.  
  386. #ifdef PRAGMA_IMPORT_OFF
  387. #pragma import off
  388. #elif PRAGMA_IMPORT
  389. #pragma import reset
  390. #endif
  391.  
  392. #ifdef __cplusplus
  393. }
  394. #endif
  395.  
  396. #endif /* __OSUTILS__ */
  397.  
  398.